import React, { Component,Suspense } from 'react';
import './App.css';
import '@/css/cssFrame.css';
import Router from '@/Router.js'
import { Provider } from 'react-redux'
import store from './store/index.js'

import  docCookies from '@/utils/do-cookie.js'
React.$docCookies = docCookies

import  api from '@/config/api.js'
React.$api = api

import  doCookie from '@/utils/do-cookie.js'
React.$doCookie = doCookie



import  config from '@/config/config.js'
React.$config = config

/*axios部分@begin*/
import axios from 'axios';
axios.defaults.baseURL = React.$config.AxiosDomain
//axios.defaults.withCredentials = true
axios.defaults.timeout = 6000
axios.interceptors.request.use(config => {
  var jwtStr = React.$docCookies.getItem(React.$config.COOKIEJWTNAME)
  config.headers = {
      'access-token': jwtStr
  }
  return config
})

axios.interceptors.response.use((config) => { 
  //只有状态码是200才会进入这里,否则就去下方的err函数
   if (config.data.errCode === -401) { 
       //-401无权限
       router.replace({path:'/login'})
       return
   }
       return config.data
}, (err) => { 
       alert('from react main.js\n'+'axios.interceptors.response.use'+'\n'+err)
})
React.$axios=axios
/*axios部分@end*/



class App extends Component {

    render(){
      return (
        <Provider store={store}>
          <Router></Router>
          </Provider>
        );
    }
}

export default App;
